<template>
  <view class="helpCenterMain">
    <view v-if="list.length > 0">
      <view class="helpCenterItem" v-for="(item, index) in list" :key="index">
        <view class="title">{{ item.type_title }}</view>
        <view class="listItemBox">
          <u-cell-item
            icon="question-circle"
            v-for="(it, i) in item.list"
            :key="i"
            :title="it.question"
            :title-style="titleStyle"
            @click="$u.route('/pages/helpCenter/helpDetail', it)"
          ></u-cell-item>
        </view>
      </view>
    </view>
    <view class="noMachine" v-if="list.length == 0 && isLoad">
      <image src="../../static/images/noData/zwtd.png" mode="widthFix"></image>
      <text>暂无数据</text>
    </view>
    <toast></toast>
  </view>
</template>

<script>
export default {
  data() {
    return {
      titleStyle: {
        "font-size": "32rpx",
        color: "#666",
      },
      list: [],
      isLoad: false,
    };
  },
  onLoad() {
    this.getHelpList();
  },
  methods: {
    getHelpList() {
      this.$u.api
        .helpCenterList()
        .then((res) => {
          if (res.status == 200) {
            this.list = res.result;
          } else {
            this.$refs.uToast.show({
              title: res.msg,
              type: "error",
              duration: 1200,
            });
          }
          this.isLoad = true;
        })        
		.catch((res) => {
          if (res.errMsg == "request:fail timeout") {
            this.$u.toast("请求超时，请重试!");
          } else if (res.errMsg == "request:fail") {
            this.$u.toast("请求失败，请重试");
          } else {
             this.$u.toast("请求失败，请重试");
          }
          this.$loading(false);
          setTimeout(() => {
            this.$u.route({
              type: "navigateBack",
              delta: 1,
            });
          }, 2000);
        });
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #fff;
}
.helpCenterItem {
  padding: 10rpx 0 0 20rpx;
  border-bottom: 10rpx solid #f1f1f1;
  .title {
    font-size: 36rpx;
    font-weight: bold;
    padding-top: 20rpx;
    padding-left: 15rpx;
    color: #333;
  }
}
</style>
